﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My;
    using ACCOUNTING.My.Resources;
    using C1.Win.C1FlexGrid;
    using C1.Win.C1FlexGrid.Util.BaseControls;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_TimDanhMuc : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("CmdAddNew")]
        private Button _CmdAddNew;
        [AccessedThroughProperty("CmdCancel")]
        private Button _CmdCancel;
        [AccessedThroughProperty("CmdOK")]
        private Button _CmdOK;
        [AccessedThroughProperty("Panel1")]
        private Panel _Panel1;
        [AccessedThroughProperty("Panel2")]
        private Panel _Panel2;
        [AccessedThroughProperty("TxtCode")]
        private TextBox _TxtCode;
        [AccessedThroughProperty("TxtName")]
        private TextBox _TxtName;
        [AccessedThroughProperty("VSlist")]
        private C1.Win.C1FlexGrid.C1FlexGrid _VSlist;
        private IContainer components;
        private string mCode;
        private bool mDanhMucTaiKhoan;
        private DataView mData;
        private DataTable mDataSource;
        private modGeneral.ListDanhMuc mLoaiDanhMuc;
        private string mTitle;
        private string mValueReturn;

        public Frm_TimDanhMuc()
        {
            base.Activated += new EventHandler(this.Frm_TimDanhMuc_Activated);
            base.Load += new EventHandler(this.Frm_TimDanhMuc_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.mTitle = "";
            this.mDanhMucTaiKhoan = false;
            this.mCode = "";
            this.InitializeComponent();
        }

        private void CmdAddNew_Click(object sender, EventArgs e)
        {
            switch (((int) this.mLoaiDanhMuc))
            {
                case 4:
                    MyProject.Forms.Frm_DMDonViBoPhan.objFrmCall = this;
                    MyProject.Forms.Frm_DMDonViBoPhan.ShowDialog();
                    break;
            }
        }

        private void CmdCancel_Click(object sender, EventArgs e)
        {
            modGeneral.H_VALUE = "";
            this.TxtCode.Text = "";
            this.TxtName.Text = "";
            this.Dispose();
        }

        private void CmdOK_Click(object sender, EventArgs e)
        {
            string str = "";
            if ((this.VSlist.Rows.Count == 1) | (this.VSlist.Row <= 0))
            {
                str = "";
            }
            else
            {
                str = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(this.VSlist[this.VSlist.Row, 0], "|"), this.VSlist[this.VSlist.Row, 1]), "|"), this.VSlist[this.VSlist.Row, 2]));
            }
            modGeneral.H_VALUE = str;
            this.TxtCode.Text = "";
            this.TxtName.Text = "";
            this.Dispose();
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Frm_TimDanhMuc_Activated(object sender, EventArgs e)
        {
            this.TxtCode.Focus();
        }

        private void Frm_TimDanhMuc_Load(object sender, EventArgs e)
        {
            if (this.mDataSource != null)
            {
                this.mData = new DataView(this.mDataSource);
                this.VSlist.DataSource = this.mData;
                this.VSlist.Cols[0].Visible = false;
                if (this.mDanhMucTaiKhoan)
                {
                    this.VSlist[0, 1] = modGeneral.Tranlated("Số t\x00e0i khoản", "");
                    this.VSlist[0, 2] = modGeneral.Tranlated("T\x00ean t\x00e0i khoản", "");
                }
                else if (this.mTitle.Trim() == "")
                {
                    this.VSlist[0, 1] = modGeneral.Tranlated("M\x00e3", "");
                    this.VSlist[0, 2] = modGeneral.Tranlated("T\x00ean", "");
                }
                else
                {
                    object instance = this.mTitle.Split(new char[] { '|' });
                    int num2 = Information.UBound((Array) instance, 1);
                    for (int i = 0; i <= num2; i++)
                    {
                        this.VSlist[0, i] = RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(instance, new object[] { i }, null));
                    }
                }
                this.VSlist.Cols[1].Width = 110;
                this.VSlist.Cols[2].Width = 100;
            }
            this.TxtCode.Text = this.mCode;
            if (this.VSlist.Rows.Count > 1)
            {
                this.VSlist.Select(1, 1);
            }
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(Frm_TimDanhMuc));
            this.Panel1 = new Panel();
            this.CmdAddNew = new Button();
            this.CmdCancel = new Button();
            this.CmdOK = new Button();
            this.VSlist = new C1.Win.C1FlexGrid.C1FlexGrid();
            this.TxtCode = new TextBox();
            this.TxtName = new TextBox();
            this.Panel2 = new Panel();
            this.Panel1.SuspendLayout();
            this.VSlist.BeginInit();
            this.Panel2.SuspendLayout();
            this.SuspendLayout();
            this.Panel1.BackColor = SystemColors.Control;
            this.Panel1.BackgroundImage = ACCOUNTING.My.Resources.Resources.bgleft;
            this.Panel1.Controls.Add(this.CmdAddNew);
            this.Panel1.Controls.Add(this.CmdCancel);
            this.Panel1.Controls.Add(this.CmdOK);
            this.Panel1.Dock = DockStyle.Bottom;
            Point point = new Point(2, 0x17f);
            this.Panel1.Location = point;
            this.Panel1.Name = "Panel1";
            Padding padding = new Padding(2);
            this.Panel1.Padding = padding;
            Size size = new Size(0x1de, 0x1d);
            this.Panel1.Size = size;
            this.Panel1.TabIndex = 3;
            this.CmdAddNew.Image = (Image) manager.GetObject("CmdAddNew.Image");
            this.CmdAddNew.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(3, 2);
            this.CmdAddNew.Location = point;
            this.CmdAddNew.Name = "CmdAddNew";
            size = new Size(0x4d, 0x18);
            this.CmdAddNew.Size = size;
            this.CmdAddNew.TabIndex = 5;
            this.CmdAddNew.Text = "&Th\x00eam";
            this.CmdAddNew.UseVisualStyleBackColor = true;
            this.CmdCancel.DialogResult = DialogResult.Cancel;
            this.CmdCancel.Image = (Image) manager.GetObject("CmdCancel.Image");
            this.CmdCancel.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0x18e, 2);
            this.CmdCancel.Location = point;
            this.CmdCancel.Name = "CmdCancel";
            size = new Size(0x4f, 0x18);
            this.CmdCancel.Size = size;
            this.CmdCancel.TabIndex = 4;
            this.CmdCancel.Text = "&Tho\x00e1t";
            this.CmdCancel.UseVisualStyleBackColor = true;
            this.CmdOK.Image = (Image) manager.GetObject("CmdOK.Image");
            this.CmdOK.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0x13b, 2);
            this.CmdOK.Location = point;
            this.CmdOK.Name = "CmdOK";
            size = new Size(0x4e, 0x18);
            this.CmdOK.Size = size;
            this.CmdOK.TabIndex = 3;
            this.CmdOK.Text = "&Chọn";
            this.CmdOK.UseVisualStyleBackColor = true;
            this.VSlist.AllowEditing = false;
            this.VSlist.BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.FixedSingle;
            this.VSlist.ColumnInfo = "3,0,0,0,0,85,Columns:0{Caption:\"Khoa\";Visible:False;}\t1{Width:115;Caption:\"Ma\";}\t2{Caption:\"Ten\";}\t";
            this.VSlist.Dock = DockStyle.Fill;
            this.VSlist.ExtendLastCol = true;
            this.VSlist.FocusRect = FocusRectEnum.None;
            point = new Point(2, 0x26);
            this.VSlist.Location = point;
            this.VSlist.Name = "VSlist";
            this.VSlist.Rows.Count = 1;
            this.VSlist.Rows.DefaultSize = 0x11;
            this.VSlist.SelectionMode = SelectionModeEnum.Row;
            size = new Size(0x1de, 0x159);
            this.VSlist.Size = size;
            this.VSlist.StyleInfo = manager.GetString("VSlist.StyleInfo");
            this.VSlist.TabIndex = 4;
            this.VSlist.VisualStyle = VisualStyle.Office2007Blue;
            point = new Point(3, 7);
            this.TxtCode.Location = point;
            this.TxtCode.Name = "TxtCode";
            size = new Size(0x69, 20);
            this.TxtCode.Size = size;
            this.TxtCode.TabIndex = 2;
            point = new Point(0x72, 7);
            this.TxtName.Location = point;
            this.TxtName.Name = "TxtName";
            size = new Size(0x169, 20);
            this.TxtName.Size = size;
            this.TxtName.TabIndex = 3;
            this.Panel2.BackgroundImage = ACCOUNTING.My.Resources.Resources.bgleft;
            this.Panel2.Controls.Add(this.TxtName);
            this.Panel2.Controls.Add(this.TxtCode);
            this.Panel2.Dock = DockStyle.Top;
            point = new Point(2, 2);
            this.Panel2.Location = point;
            this.Panel2.Name = "Panel2";
            size = new Size(0x1de, 0x24);
            this.Panel2.Size = size;
            this.Panel2.TabIndex = 5;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            this.BackColor = SystemColors.ButtonFace;
            this.CancelButton = this.CmdCancel;
            size = new Size(0x1e2, 0x19e);
            this.ClientSize = size;
            this.ControlBox = false;
            this.Controls.Add(this.VSlist);
            this.Controls.Add(this.Panel2);
            this.Controls.Add(this.Panel1);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.Name = "Frm_TimDanhMuc";
            padding = new Padding(2);
            this.Padding = padding;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "TIM DANH MUC";
            this.Panel1.ResumeLayout(false);
            this.VSlist.EndInit();
            this.Panel2.ResumeLayout(false);
            this.Panel2.PerformLayout();
            this.ResumeLayout(false);
        }

        public void Search(string strCode, string strName)
        {
            try
            {
                string left = "";
                if (strCode.Trim() != "")
                {
                    left = "Ma LIKE '" + strCode + "%'";
                }
                if (strName.Trim() != "")
                {
                    left = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(left, Interaction.IIf(left.Trim() != "", " And Ten LIKE '" + strName + "%'", " Ten LIKE '" + strName + "%'")));
                }
                this.mData.RowFilter = left;
                if (this.VSlist.Rows.Count != 1)
                {
                    this.VSlist.Select(1, 0, 1, this.VSlist.Cols.Count - 1);
                }
                this.VSlist.Cols[1].Width = 110;
                this.VSlist.Cols[2].Width = 100;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
        }

        private void TxtCode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                this.CmdOK_Click(RuntimeHelpers.GetObjectValue(sender), e);
            }
            if (e.KeyCode == Keys.Down)
            {
                if (this.VSlist.Row < (this.VSlist.Rows.Count - 1))
                {
                    this.VSlist.Select(this.VSlist.Row + 1, 1);
                }
                e.SuppressKeyPress = true;
            }
            if (e.KeyCode == Keys.Up)
            {
                if (this.VSlist.Row > 1)
                {
                    this.VSlist.Select(this.VSlist.Row - 1, 1);
                }
                e.SuppressKeyPress = true;
            }
        }

        private void TxtCode_TextChanged(object sender, EventArgs e)
        {
            this.Search(this.TxtCode.Text, this.TxtName.Text);
        }

        private void TxtName_TextChanged(object sender, EventArgs e)
        {
            this.Search(this.TxtCode.Text, this.TxtName.Text);
        }

        private void VSlist_DoubleClick(object sender, EventArgs e)
        {
            this.CmdOK_Click(RuntimeHelpers.GetObjectValue(sender), e);
        }

        internal virtual Button CmdAddNew
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdAddNew;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdAddNew_Click);
                if (this._CmdAddNew != null)
                {
                    this._CmdAddNew.Click -= handler;
                }
                this._CmdAddNew = value;
                if (this._CmdAddNew != null)
                {
                    this._CmdAddNew.Click += handler;
                }
            }
        }

        internal virtual Button CmdCancel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdCancel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdCancel_Click);
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click -= handler;
                }
                this._CmdCancel = value;
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click += handler;
                }
            }
        }

        internal virtual Button CmdOK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdOK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdOK_Click);
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click -= handler;
                }
                this._CmdOK = value;
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click += handler;
                }
            }
        }

        public string Code
        {
            get
            {
                return this.mCode;
            }
            set
            {
                this.mCode = value;
            }
        }

        public bool DanhMucTaiKhan
        {
            get
            {
                return this.mDanhMucTaiKhoan;
            }
            set
            {
                this.mDanhMucTaiKhoan = value;
            }
        }

        internal virtual Panel Panel1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel1 = value;
            }
        }

        internal virtual Panel Panel2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel2 = value;
            }
        }

        public DataTable SourceTable
        {
            get
            {
                return this.mDataSource;
            }
            set
            {
                this.mDataSource = value;
            }
        }

        public string TitleOfCollumn
        {
            get
            {
                return this.mTitle;
            }
            set
            {
                this.mTitle = value;
                object instance = this.mTitle.Split(new char[] { '|' });
                int num2 = Information.UBound((Array) instance, 1) - 1;
                for (int i = 0; i <= num2; i++)
                {
                    this.VSlist[0, i] = RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(instance, new object[] { i }, null));
                }
            }
        }

        internal virtual TextBox TxtCode
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtCode;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.TxtCode_TextChanged);
                KeyEventHandler handler2 = new KeyEventHandler(this.TxtCode_KeyDown);
                if (this._TxtCode != null)
                {
                    this._TxtCode.TextChanged -= handler;
                    this._TxtCode.KeyDown -= handler2;
                }
                this._TxtCode = value;
                if (this._TxtCode != null)
                {
                    this._TxtCode.TextChanged += handler;
                    this._TxtCode.KeyDown += handler2;
                }
            }
        }

        internal virtual TextBox TxtName
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtName;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.TxtName_TextChanged);
                if (this._TxtName != null)
                {
                    this._TxtName.TextChanged -= handler;
                }
                this._TxtName = value;
                if (this._TxtName != null)
                {
                    this._TxtName.TextChanged += handler;
                }
            }
        }

        public string ValueReturn
        {
            get
            {
                return this.mValueReturn;
            }
            set
            {
                this.mValueReturn = value;
            }
        }

        internal virtual C1.Win.C1FlexGrid.C1FlexGrid VSlist
        {
            [DebuggerNonUserCode]
            get
            {
                return this._VSlist;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.VSlist_DoubleClick);
                if (this._VSlist != null)
                {
                    this._VSlist.DoubleClick -= handler;
                }
                this._VSlist = value;
                if (this._VSlist != null)
                {
                    this._VSlist.DoubleClick += handler;
                }
            }
        }
    }
}

